package com.agile.leetcode.hutool.convert;


import cn.hutool.core.convert.Converter;
import cn.hutool.core.convert.ConverterRegistry;
import org.junit.Assert;

/**
 * @Author：chenzhangkun
 * @Date：2023/10/19 17:13
 */
public class ConverterRegistryDemo {

    public static void main(String[] args) {
        ConverterRegistry converterRegistry = ConverterRegistry.getInstance();
        converterRegistry.putCustom(String.class, ConverterRegistryDemo.OwnConvert.class);
        int a = 454553;
        String result = converterRegistry.convert(String.class, a);
        Assert.assertEquals("Custom: 454553", result);
    }
    public static class OwnConvert implements Converter<String> {
        @Override
        public String convert(Object o, String o2) throws IllegalArgumentException {
            return "Custom: "+o.toString();
        }
    }
}

